﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Petaframe.DataAccess
{
    class ObjectParameterCommand<T> : ICommandBuilder, IDisposable
    {
        Func<T, int> _callback;
         readonly T _item;
         public ObjectParameterCommand(T item, Func<T, int> callback)
        {
            _callback = callback;
            _item = item;
        }

        public void Execute()
        {
            _callback(_item);
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _callback = null;                
            }
        }
        ~ObjectParameterCommand()
        {
            Dispose(false);
        }
       
    }
}
